package elitech.vietnam.weatherfashion.weatherservice;

import java.util.Date;

import elitech.vietnam.weatherfashion.ultilities.Utilities;

public class WeatherDayObject {

	private String type;
	private String templateUp;
	private String templateDown;
	private String templateAverage;
	private String templateDay;
	private String templateNight;
	private String date;
	private String day;

	public WeatherDayObject(String type, String templateUp,
			String templateDown, String templateAverage, String templateDay,
			String templateNight, String date) {
		super();
		this.type = type;
		this.templateUp = templateUp;
		this.templateDown = templateDown;
		this.templateAverage = templateAverage;
		this.templateDay = templateDay;
		this.templateNight = templateNight;
		this.date = date;
		this.day = Utilities.convertDateFormat(date, "yyyy-MM-dd", "E");
		// this.iconResourceId =
		// Utilities.getDrawableFromTypeOfWeather(this.type);
	}

	public WeatherDayObject() {
		// TODO Auto-generated constructor stub
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getTemplateUp() {
		return templateUp;
	}

	public void setTemplateUp(String templateUp) {
		this.templateUp = templateUp;
	}

	public String getTemplateDown() {
		return templateDown;
	}

	public void setTemplateDown(String templateDown) {
		this.templateDown = templateDown;
	}

	public String getDay() {
		return day;
	}

	public void setDay(String day) {
		this.day = day;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getTemplateAverage() {
		return templateAverage;
	}

	public void setTemplateAverage(String templateAverage) {
		this.templateAverage = templateAverage;
	}

	// public String getTemplateDay() {
	// return templateDay;
	// }
	//
	// public void setTemplateDay(String templateDay) {
	// this.templateDay = templateDay;
	// }
	//
	// public String getTemplateNight() {
	// return templateNight;
	// }
	//
	// public void setTemplateNight(String templateNight) {
	// this.templateNight = templateNight;
	// }

	@SuppressWarnings("deprecation")
	public String getCurrentTemplate() {

		try {
			Date d = new Date(System.currentTimeMillis());

			float dayTempF = Float.parseFloat(templateDay);
			float nightTempF = Float.parseFloat(templateNight);

			int dayTemp = (int) dayTempF;
			int nightTemp = (int) nightTempF;
			if (dayTemp == nightTemp)
				return String.format("%.1f", (dayTempF + nightTempF) / 2);

			if (d.getHours() >= 6 && d.getHours() < 19) {
				return String.valueOf(dayTemp);
			} else {
				return String.valueOf(nightTemp + 1);
			}
		} catch (Exception ex) {
			return "";
		}
	}
}
